//
//  ShopInfoViewController.m
//  CarManager
//
//  Created by 王森林 on 2019/1/22.
//  Copyright © 2019年 王森林. All rights reserved.
//

#import "ShopInfoViewController.h"
#import "UserRes.h"
@interface ShopInfoViewController ()
@property (nonatomic, strong) NSDictionary *resultDict;
@end

@implementation ShopInfoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"门店信息";
//    [self createUI];
    [self fetchDataWithNet];
    // Do any additional setup after loading the view.
}

- (void)fetchDataWithNet
{
    
    
    UserRes  *user = [CommonMethod getUser];
    if (!user) {
        [[NSNotificationCenter defaultCenter]postNotificationName:NotificationCenterName_AlertLoginVC object:nil];
        return;
    }
    NSDictionary *params = @{
                             @"FKEY":[CommonMethod createMD5Key:@"TOKEN"],
                             @"TOKEN":user.TOKEN,
                             @"USERNAME":user.mobile
                             };
    
    
    
    [[ZY_AfnNetManager shareInstance]postWithURL:Car_API_11 params:params md5Paraname:nil success:^(id  _Nullable response) {
        
        dispatch_async(dispatch_get_main_queue(), ^{
            [SVProgressHUD dismiss];
        });
        
        self.resultDict  = [response objectForKey:@"info"];
        [self createUI];
        
        
    } fail:^(NSError * _Nonnull error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [SVProgressHUD showErrorWithStatus:error.localizedDescription];
        });
        
    }];
    
    
}

- (void)createUI
{
    UIImageView *topImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, BOUNDWIDTH, 200)];
    [topImageView sd_setImageWithURL:[NSURL URLWithString:APPEND_URL(BASE_URL, [self.resultDict objectForKey:@"MDTP00"])]];
    [self.view addSubview:topImageView];
    
    UIView *companyView = [[UIView alloc] initWithFrame:CGRectMake(0, 200, BOUNDWIDTH, 35)];
    companyView.backgroundColor = Common_HeadTitle_Color;
    [self.view addSubview:companyView];
   
    
    UIImageView *imageView1 = [[UIImageView alloc] initWithFrame:CGRectMake(15, 10, 15, 15)];
    imageView1.image = IMG(@"cardetail_1");
    [companyView addSubview:imageView1];

    
    UIImageView *imageView2 = [[UIImageView alloc] initWithFrame:CGRectMake(40, 10, 15, 15)];
    imageView2.image = IMG(@"cardetail_2");
    [companyView addSubview:imageView2];
 
    
    
    UILabel  *companyLabel = [[UILabel alloc]initWithFrame:CGRectMake(65, 10, BOUNDWIDTH - 80, 15)];
    companyLabel.textColor = [UIColor whiteColor];
    companyLabel.font = FONT_SIZE(14);
//    companyLabel.text = [infoDict objectForKey:@"JXSMC0"];
    companyLabel.text = [self.resultDict objectForKey:@"NAME00"];
    [companyView addSubview:companyLabel];
    
    UIView *bottomView = [[UIView alloc]init];
    bottomView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:bottomView];
    
    //负责人
    UILabel *circleLabel1 = [[UILabel alloc] initWithFrame:CGRectMake(15, 25, 10, 10)];
    circleLabel1.backgroundColor = [UIColor blackColor];
    circleLabel1.layer.cornerRadius  =5;
    circleLabel1.layer.masksToBounds = YES;
    [bottomView addSubview:circleLabel1];
    UILabel *titleLabel1 = [[UILabel alloc]initWithFrame:CGRectMake(35, 22, BOUNDWIDTH - 50, 14)];
    titleLabel1.text = [NSString stringWithFormat:@"负责人:%@",[self.resultDict objectForKey:@"LXR000"]];
    titleLabel1.textColor = Common_TextColor;
    titleLabel1.font = FONT_SIZE(14);
    [bottomView addSubview:titleLabel1];
    
    //联系电话
    UILabel *circleLabel2 = [[UILabel alloc] initWithFrame:CGRectMake(15, 55, 10, 10)];
    circleLabel2.backgroundColor = [UIColor blackColor];
    circleLabel2.layer.cornerRadius  =5;
    circleLabel2.layer.masksToBounds = YES;
    [bottomView addSubview:circleLabel2];
    UILabel *titleLabel2 = [[UILabel alloc]initWithFrame:CGRectMake(35, 52, BOUNDWIDTH - 50, 14)];
    titleLabel2.text = [NSString stringWithFormat:@"联系电话:%@",[self.resultDict objectForKey:@"LXDH00"]];
    titleLabel2.textColor = Common_TextColor;
    titleLabel2.font = FONT_SIZE(14);
    [bottomView addSubview:titleLabel2];
    
    
    //地址
    UILabel *circleLabel3 = [[UILabel alloc] initWithFrame:CGRectMake(15, 85, 10, 10)];
    circleLabel3.backgroundColor = [UIColor blackColor];
    circleLabel3.layer.cornerRadius  =5;
    circleLabel3.layer.masksToBounds = YES;
    [bottomView addSubview:circleLabel3];
    
    NSString *str  =  [NSString stringWithFormat:@"地址:%@",[self.resultDict objectForKey:@"DZ0000"]];
     CGSize size = [CommonMethod labWidthFromStr:str andFont:FONT_SIZE(14) andWidth:BOUNDWIDTH -50];
    UILabel *titleLabel3 = [[UILabel alloc]initWithFrame:CGRectMake(35, 82, BOUNDWIDTH - 50, size.height)];
    titleLabel3.text = str;
    titleLabel3.textColor = Common_TextColor;
    titleLabel3.font = FONT_SIZE(14);
    titleLabel3.numberOfLines = 0;
    [bottomView addSubview:titleLabel3];
    
    bottomView.frame = CGRectMake(0, 235, BOUNDWIDTH, 82+size.height+10);
    
  
    
    
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
